app.controller('articleCtrl', ['$rootScope', '$scope', '$http', '$state', '$stateParams','$location','$anchorScroll',
  function($rootScope, $scope, $http, $state,$stateParams,$location,$anchorScroll) {
  	var vm=this;
  	$http.get('/api/articles/'+$stateParams.id)
  	.success(function(res){
  		vm.article=res.data;
  		$rootScope.title = $rootScope.title+' - '+vm.article.title;
  	})
  	.error(function(res){
  		vm.article={};
  	});
    
    $scope.goto=function(anchor){
    	$location.hash(anchor);
    	$anchorScroll();
    }
  }
]);
